package com.zh.edu.info.manager.service;

import com.zh.edu.info.manager.dao.TeacherDao;
import com.zh.edu.info.manager.domain.Teacher;

public class TeacherService {
    private TeacherDao teacherDao = new TeacherDao();
    public boolean idFind(String id) {
        Teacher[] teacher = teacherDao.arrFind();
        boolean flog = false;
        for (int i = 0; i < teacher.length; i++) {
            if(teacher[i] != null && teacher[i].getId().equals(id)) {
                flog = true;
                break;
            }
        }
        return flog;
    }

    public void addTeacher(Teacher teacher) {
        teacherDao.addTeacher(teacher);
    }

    public Teacher[] showTeacher() {
        Teacher[] teacher = teacherDao.arrFind();
        boolean flog = false;
        for (int i = 0; i < teacher.length; i++) {
            if (teacher[i] != null) {
                flog = true;
                break;
            }
        }
        if(flog) {
            return teacher;
        }else {
            return null;
        }
    }


    public void selectTeacher(String id) {
        teacherDao.selectTeacher(id);
    }

    public void updateTeacher(String id, Teacher teacher) {
        teacherDao.updateTeacher(id, teacher);
    }
}
